package muilty_thread;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author zzMh
 * @Description TODO
 */
public class ABC implements Runnable{
    public ABC(char target) {
        this.target = target;
    }

    private char target;
    private static AtomicInteger atomicInteger = new AtomicInteger(0);
    private final static int cnt = 30;
    private static final char[] strs = {'a', 'b', 'c'};
    public static void main(String[] args) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(3, 3, 20, TimeUnit.MINUTES, new LinkedBlockingDeque<>());
        executor.execute(new ABC('a'));
        executor.execute(new ABC('b'));
        executor.execute(new ABC('c'));
        executor.shutdown();

    }


    @Override
    public void run() {
        while (atomicInteger.get() < 30) {
            if (strs[atomicInteger.get() % 3] == target) {
                System.out.printf("%c ", target);
                int i = atomicInteger.incrementAndGet();
                System.out.println(i);
            }
        }
    }
}
